import java.util.ArrayList;
import java.util.List;


public class CheckPalindrome {

	
	public static boolean isPalindrome(String str){
		for(int i = 0; i< str.length()/2; i++){
			if(str.charAt(i) != str.charAt(str.length()- i - 1)){
				return false;
			}
		}
		return true;
	}
	//Determine whether an integer is a palindrome. Do this without extra space.
	public static boolean ParlindromeNum( int n )
	{
		assert( n > 0 );
		
		int digits = 1;
		while( n / digits >= 10 )
		{
			digits *= 10;
		}

		while( n > 0 )
		{
			int right = n % 10;
			int left = n / digits;
			if( right != left )
			{
				return false;
			}
			n = ( n % digits) / 10;
			digits /= 100;
		}
		return true;
	}
	
	public static boolean ParlindromeNum2(int n){
		if(n < 0){
			return false;
		}
		
		int num = n;
		
		List<Integer> arraylist = new ArrayList<Integer>();
		while(num != 0){
			arraylist.add(num % 10);
			num /= 10;
		}
		
		for(int i = 0; i < arraylist.size(); i++){
			if(arraylist.get(i) != arraylist.get(arraylist.size()-1- i)){
				return false;
			}
		}
		
		return true;
		
		
		
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.out.print(CheckPalindrome.isPalindrome("a"));
		System.out.print(CheckPalindrome.ParlindromeNum2(0));
	}

}
